home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 March
/
EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso
/
earcd
/
comm2
/
deldps10.lha
/
DelDupes.br
Wrap
Text File
|
1995-08-28
|
3KB
|
107 lines
/*
** $VER: DelDupes.br 1.0 (28.8.95)
** by Eirik Nicolai Synnes
**
** This script will delete duplicate entries in the file database. The first
** occurence of each filename will be kept, subsequent occurences in any file
** area will be deleted (currently, I'll do something about this later).
**
** After running I'd recommend you use "Maintainance" in Thor's file database
** window.
**
**
** Usage: DelDupes.br <SYSTEM>
**
** Ideas: GUI interface if run from Thor
** Use bbsread's READARGS
** Allow identical filenames across file areas
** An ALL command line switch to scan all systems
** Optionally pack file data
**
*/
options results
signal on break_c
signal on halt
/* Find BBSREAD ARexx ports' */
if ~show('p', 'BBSREAD') then do; address command; "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"; "WaitForPort BBSREAD"; end
/* Parse command line arguments */
parse arg system
system = strip(system, 'B', '"')
if system = '' then do
say 'Usage: DelDupes.br <SYSTEM>'
exit(0)
end
/* Initialize variables */
checked = 0; totchecked = 0; dupes = 0; dupeshere = 0
FDF_DELETED = '00000001'x
/* Start the work... */
address(BBSREAD)
GETFAREALIST BBSNAME '"'system'"' STEM fareas
if rc ~= 0 then do; say BBSREAD.LASTERROR; exit(0); end
if fareas.COUNT = 0 then do
say 'No file areas on this system.'
exit(0)
end
say '1B'x'[4mChecking for dupes on "'system'" - 'fareas.COUNT' file areas.' || '1B'x'[0m' || '1B'x'[1B'
do i = 1 to fareas.COUNT
drop fadata.
GETFAREADATA BBSNAME '"'system'"' FAREANAME '"'fareas.i'"' STEM fadata
if rc ~= 0 then do; say BBSREAD.LASTERROR; exit(0); end
say '1B'x'[1A' || '1B'x'[K' || '1B'x'[1m'fareas.i || '1B'x'[0m'
say '1B'x'[1A' || '1B'x'[20Ccontains 'fadata.NUMFILES' files.'
say '1B'x'[1A' || '1B'x'[42C' || '1B'x'[3mProcessing...' || '1B'x'[0m' || '1B'x'[1B'
thisfile = fadata.FIRSTFILE
if fadata.NUMFILES > 0 then do until checked = fadata.NUMFILES
drop filetags. filedata. found.
READBRFILE BBSNAME '"'system'"' FAREANAME '"'fareas.i'"' FILENR thisfile TAGSSTEM filetags DATASTEM filedata
if rc ~= 0 then do; say BBSREAD.LASTERROR; exit(0); end
nextfile = result
if (bitand(DATA.FLAGS,FDF_DELETED) ~= FDF_DELETED) then do
SEARCHBRFILE BBSNAME '"'system'"' STEM found SEARCH '"'filetags.NAME'"' NAME
if rc ~= 0 then do; say BBSREAD.LASTERROR; exit(0); end
do j = 1 to found.FILEAREA.COUNT
do k = 1 to found.FILE.j.COUNT
if found.FILE.j.k ~= thisfile then do
say '1B'x'[1A' || '1B'x'[KDupe: 'found.FILEAREA.j'/'filetags.NAME
WRITEBRFILE BBSNAME '"'system'"' FAREANAME '"'found.FILEAREA.j'"' UPDATEFILENR found.FILE.j.k DELETEFILE
if rc ~= 0 then do; say BBSREAD.LASTERROR; exit(0); end
say '1B'x'[1A' || '1B'x'[42CDELETED'
dupes = dupes + 1; dupeshere = dupeshere + 1
end
end
end
checked = checked + 1; totchecked = totchecked + 1
thisfile = nextfile
end
end
say '1B'x'[2A' || '1B'x'[42C' || '1B'x'[K'dupeshere' dupes found.' || '1B'x'[1B'
checked = 0; dupeshere = 0
end
break_c:
halt:
say 'Checked 'totchecked' files and found 'dupes' duplicates.'